$(function () {
    $("#selectAll").click(function () {
        $(".all_selectList option").appendTo($(".selected_selectList"));
    });
    $("#deselectAll").click(function () {
        $(".selected_selectList option").appendTo($(".all_selectList"));
    });
    $("#select").click(function () {
        $(".all_selectList option:selected").appendTo($(".selected_selectList"));
    });
    $("#deselect").click(function () {
        $(".selected_selectList option:selected").appendTo($(".all_selectList"));
    });
    //把已有的权限从权限列表中移除
    var ids = $.map($(".selected_selectList option"),function (item) {
        return item.value;
    });
    $.each($(".all_selectList option"),function (index,item) {
        var id = item.value;
        if($.inArray(id,ids)>=0){
            $(item).remove();
        }
    });
    $("#editForm").submit(function () {
        $(".selected_selectList option").prop("selected",true);
        $(".mselected_selectList option").prop("selected",true);
    });
});
$(function () {
    $("#mselectAll").click(function () {
        $(".mall_selectList option").appendTo($(".mselected_selectList"));
    });
    $("#mdeselectAll").click(function () {
        $(".mselected_selectList option").appendTo($(".mall_selectList"));
    });
    $("#mselect").click(function () {
        $(".mall_selectList option:selected").appendTo($(".mselected_selectList"));
    });
    $("#mdeselect").click(function () {
        $(".mselected_selectList option:selected").appendTo($(".mall_selectList"));
    });
    //把已有的权限从权限列表中移除
    var ids = $.map($(".mselected_selectList option"),function (item) {
        return item.value;
    });
    $.each($(".mall_selectList option"),function (index,item) {
        var id = item.value;
        if($.inArray(id,ids)>=0){
            $(item).remove();
        }
    });
});